/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpa.entities;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Usuario
 */
@Entity
@Table(name = "diametro_nominal")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DiametroNominal.findAll", query = "SELECT d FROM DiametroNominal d"),
    @NamedQuery(name = "DiametroNominal.findByIdDiametroNominal", query = "SELECT d FROM DiametroNominal d WHERE d.idDiametroNominal = :idDiametroNominal"),
    @NamedQuery(name = "DiametroNominal.findByValor", query = "SELECT d FROM DiametroNominal d WHERE d.valor = :valor"),
    @NamedQuery(name = "DiametroNominal.findByTipoEnsayo", query = "SELECT d FROM DiametroNominal d WHERE d.tipoEnsayo = :tipoEnsayo")})
public class DiametroNominal implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_diametro_nominal")
    private Short idDiametroNominal;
    @Basic(optional = false)
    @Column(name = "valor")
    private float valor;
    @Basic(optional = false)
    @Column(name = "tipo_ensayo")
    private String tipoEnsayo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "diametroNominalIdDiametroNominal")
    private List<Ensayo> ensayoList;

    public DiametroNominal() {
    }

    public DiametroNominal(Short idDiametroNominal) {
        this.idDiametroNominal = idDiametroNominal;
    }

    public DiametroNominal(Short idDiametroNominal, float valor, String tipoEnsayo) {
        this.idDiametroNominal = idDiametroNominal;
        this.valor = valor;
        this.tipoEnsayo = tipoEnsayo;
    }

    public Short getIdDiametroNominal() {
        return idDiametroNominal;
    }

    public void setIdDiametroNominal(Short idDiametroNominal) {
        Short oldIdDiametroNominal = this.idDiametroNominal;
        this.idDiametroNominal = idDiametroNominal;
        changeSupport.firePropertyChange("idDiametroNominal", oldIdDiametroNominal, idDiametroNominal);
    }

    public float getValor() {
        return valor;
    }

    public void setValor(float valor) {
        float oldValor = this.valor;
        this.valor = valor;
        changeSupport.firePropertyChange("valor", oldValor, valor);
    }

    public String getTipoEnsayo() {
        return tipoEnsayo;
    }

    public void setTipoEnsayo(String tipoEnsayo) {
        String oldTipoEnsayo = this.tipoEnsayo;
        this.tipoEnsayo = tipoEnsayo;
        changeSupport.firePropertyChange("tipoEnsayo", oldTipoEnsayo, tipoEnsayo);
    }

    @XmlTransient
    public List<Ensayo> getEnsayoList() {
        return ensayoList;
    }

    public void setEnsayoList(List<Ensayo> ensayoList) {
        this.ensayoList = ensayoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDiametroNominal != null ? idDiametroNominal.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DiametroNominal)) {
            return false;
        }
        DiametroNominal other = (DiametroNominal) object;
        if ((this.idDiametroNominal == null && other.idDiametroNominal != null) || (this.idDiametroNominal != null && !this.idDiametroNominal.equals(other.idDiametroNominal))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return String.valueOf(valor);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
